package cc.vv.btpartyjob.partymanager.delegate

import android.view.View
import android.widget.RelativeLayout
import android.widget.TextView
import cc.vv.baselibrary.util.LKTimeUtil
import cc.vv.baselibrary.util.LKToastUtil
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.btpartyjob.partymanager.R
import cc.vv.btpartyjob.partymanager.moudel.bean.AddResourceObj
import cc.vv.btpartyjob.partymanager.view.ReportResourceView
import cc.vv.mvp.delegate.BaseAppDelegate
import java.util.ArrayList

/**
 * 添加单位报到托管类
 * Created by Chen.qi on 2018/10/24.
 */
class AddUnitReportActivityDelegate : BaseAppDelegate() {

    override fun initWidget() {

    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_unit_report_add
    }

    /**设置标题title*/
    fun setTopBarTitle(topBarTitle: String) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_auRA_topBar)
        titleBar?.setTitle(topBarTitle)
    }


    /**设置标题右边按钮点击事件*/
    fun setTitleBackBtnOnClick(event: BaseTopBarView.EventInterface) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_auRA_topBar)
        titleBar?.setEventInterface(event)
    }


    /**
     * 负责人姓名
     */
    fun getPrincipalName(): String {
        val tvPrName = getView<TextView>(R.id.et_auRA_principalName)
        return tvPrName?.text.toString().trim()
    }

    /**
     * 负责人姓名
     */
    fun getMobile(): String {
        val tvPrName = getView<TextView>(R.id.et_auRA_partyCode)
        return tvPrName?.text.toString().trim()
    }


    /**
     * 党员人数
     */
    fun getPartyPerNum(): String {
        val tvPerNum = getView<TextView>(R.id.et_auRA_partyNum)
        return tvPerNum?.text.toString().trim()
    }

    /**
     * 单位地址
     */
    fun getUnitAddress(): String {
        val tvAddress = getView<TextView>(R.id.et_auRA_partyAddress)
        return tvAddress?.text.toString().trim()
    }

    /**
     * 邮编
     */
    fun getUnitCode(): String {
        val tvCode = getView<TextView>(R.id.et_auRA_partyCode)
        return tvCode?.text.toString().trim()
    }


    /**
     * 报到街道
     */
    fun setStreetName(streetName: String?) {
        val tvStreet = getView<TextView>(R.id.tv_auRA_jieDaoInfo)
        tvStreet?.text = streetName
    }

    /**
     * 报到社区
     */
    fun setCommunityName(communityName: String?) {
        val tvCommunity = getView<TextView>(R.id.tv_auRA_sheQuInfo)
        tvCommunity?.text = communityName
    }

    /**
     * 获取单位名称
     */
    fun setUnitName(unitName: String?) {
        val tvUnitName = getView<TextView>(R.id.tv_auRA_unitName)
        tvUnitName?.text = unitName
    }

    /**
     * 报到时间
     */
    fun setReportTime() {
        val tvReportTime = getView<TextView>(R.id.tv_auRA_registerTime)
        val currentTimeMillis = System.currentTimeMillis()
        tvReportTime?.text = LKTimeUtil.getInstance().formatTime("yyyy-MM-dd", currentTimeMillis)
    }

    /**
     * 资源列表
     */
    fun setListData(optionList: ArrayList<AddResourceObj>?) {
        val tvReportTime = getView<ReportResourceView>(R.id.rpv_auRA_repView)
        val tvDesc = getView<TextView>(R.id.tv_auRA_desc)
        if (optionList!!.size > 0) {
            tvDesc?.visibility = View.VISIBLE
        } else {
            tvDesc?.visibility = View.GONE
        }
        tvReportTime?.addAllSelectedFileView(optionList)
    }
}